43. 解决方案: AND 和 BETWEEN
AND 和 BETWEEN 问题的解决方案
-
SELECT * FROM orders WHERE standard_qty > 1000 AND poster_qty = 0 AND gloss_qty = 0;
2.
SELECT name
FROM accounts
WHERE name NOT LIKE 'C%' AND name LIKE '%s';
- 你可能会觉得对日期数据使用 BETWEEN 不太好理解。对于单纯的日期数据而言(只包含年月日不包含时间的数据,比如 '2016-12-31'),其默认时间为日期当天的 00:00:00(也就是午夜时分),而 BETWEEN 通常是不包含端点在内的,这也是为什么将右边的时间点设置为 '2017-01-01' 的原因。
SELECT *
FROM web_events
WHERE channel IN ('organic', 'adwords') AND occurred_at BETWEEN '2016-01-01' AND '2017-01-01'
ORDER BY occurred_at DESC;